<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>

<h1>Správa projektů</h1>
<h2>Seznam projektů</h2>
<p>
    <a href="<c:url value="create" />">Vytvořit nový projekt</a>
</p>

<table>
    <tr>
        <th>ID</th>
        <th>Název</th>
        <th>Popis</th>
        <th>Stav</th>  
        <th>Repositář</th>  
        <th>Volby</th>    
    </tr>
    
    <c:if test="${projects != null}">
        <c:forEach items="${projects}" var="item">
            <tr>
                <td><c:out value="${item.id}" /></td>
                <td><c:out value="${item.name}" /></td>
                <td><c:out value="${item.description}" /></td>
                <td><c:out value="${item.state.name}" /></td>
                <td><c:out value="${item.repository.url}" /></td>
                <td>
                    <c:url var="projectUrl" value="detail">
                        <c:param name="id" value="${item.id}"/>
                    </c:url>
                
                    <a href="${projectUrl}">detail</a>
                    <a href="<c:url value="edit?id=${item.id}"/>">edit</a>
                </td>
            </tr>
        </c:forEach>
    </c:if>
</table>

</body>
</html>